package org.mikeliu.review.fun1;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Octagon a1 = new Octagon(input.nextDouble());
        System.out.printf("Area is %.2f\n", a1.getArea());
        System.out.println("Perimeter is " + a1.getPerimeter());
        Octagon a2 = (Octagon) a1.clone();
        System.out.println("Compare the methods " + a1.compareTo(a2));
    }
}

/* 请在这里填写答案 */
class Octagon implements Comparable<Octagon>,Cloneable{

	private double side;
	
	
	public Octagon(double side) {
		this.side = side;
	}

	public double getSide() {
		return side;
	}

	public void setSide(double side) {
		this.side = side;
	}

	public double getPerimeter(){
		return 8*side;
	}
	
	public double getArea(){
		return (2+4/Math.sqrt(2))*side*side;
	}

    @Override
    public int compareTo(Octagon o){
          if(this.side>o.side)return 1;
          else if(this.side<o.side)return -1;
          else return 0;
    }
    @Override
    protected Object clone() {
        return this;
    }
}
